<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
    <title></title>
    <link rel="stylesheet" href="../css/mui.min.css" />
    <link rel="stylesheet" type="text/css" href="../css/style.css"/>
    <link rel="stylesheet" href="../css/iconfont.css" />
    
    <style type="text/css">
    	html,body{
    		width: 100%;
    		height: 100%;
    	}
    	#mask1{ 
    		width: 7rem;
    		height: 3.33333rem;
    		background-image: url('../images/sys_logo.png');
    		background-repeat: repeat;
    		background-size:100% 100%;
    		position: absolute;
    		top:44px; left: 0;
    		z-index: 100;
    	}
    </style>
</head>
<body>
	<header class="mui-bar mui-bar-nav public-green-bgcolor header-no-shadow header-txt-color">
	    <a id='back' class="mui-icon mui-icon-left-nav mui-pull-left"></a>
	    <a id='refresh' class="mui-icon chaticonfont chat_icon-shuaxin mui-pull-right"></a>
	    <h1 class="mui-title">电影</h1>
	</header>
	
	<div class="mui-content" style="position: relative;height: 100%;">
		<div id="mask1"></div>
	    <iframe id='movies' name='movies' src="http://m.aaqqc.com/" width="100%" height="100%"></iframe>
	    <div id="mask2"></div>
	</div>
	

<script src="../lib/js/mui.min.js"></script>
<script src="../lib/js/jquery-3.2.1.min.js"></script>
<script src="../lib/js/my_plugin.js"></script>
<script>
var iframe = document.getElementById("movies");

castapp.init();
mui.init();
mui.plusReady(function(){
	//按手机返回键
	var lastTime = Date.now();
	mui.back = function(){
		var now = Date.now();
		if(now - lastTime <500){ //两次时间间隔不超过500毫秒
			plus.runtime.quit();
		}else{
			castapp.prompt('再按一次退出程序');
			lastTime = now;
		}
	}
});

$(function(){
	var body_H = $(window).height();
	//剩下的高度为
	var free_H = body_H - 44;
	
	$('.mui-content').height(free_H);
	
	
	
	//点击返回键
	$('#back').get(0).addEventListener('tap',function(){
		document.getElementById('movies').contentWindow.history.back();
	});
	
	//点击刷新按钮
	$('#refresh').get(0).addEventListener('tap',function(e){
		e.preventDefault();
		document.getElementById('movies').contentWindow.location.reload(true);
		check_load();
	});
	
 	//检查iframe是否加载完
 	check_load();
 	function check_load(){
 		castapp.showWaiting('刷新中...');
 		if (iframe.attachEvent) {    
	        iframe.attachEvent("onload", function() {    
	            //iframe加载完成后你需要进行的操作  
	            clear();
	            castapp.closeWaiting();
	        });    
	    } else {    
	        iframe.onload = function() {    
	            //iframe加载完成后你需要进行的操作  
	            clear();
	            castapp.closeWaiting();
	        };    
	    }  
 	}
    
    
    //清除广告
    function clear(){
    	var iframe_content = iframe.contentWindow.document.body.innerHTML;
    	var $iframe_content = $(iframe_content);
    	var $div_eles = $iframe_content.find('div');
    	var $my_div = $div_eles.eq($div_eles.length-1);
    	$my_div.remove();
    }
	
});
	
	
</script>

</body>
</html>